package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUserPost;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.ISysUserPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserPostServiceImpl implements ISysUserPostService {
    @Autowired
    private SysUserPostMapper userPostMapper;
    @Autowired
    private SysPostMapper postMapper;

    @Override
    public int deleteByUserId(Long userId) {
        LambdaUpdateWrapper<SysUserPost> updateWrapper = new LambdaUpdateWrapper<SysUserPost>()
                .eq(SysUserPost::getUserId, userId);
        return userPostMapper.delete(updateWrapper);
    }

    @Override
    public void saveList(List<SysUserPost> list) {
        userPostMapper.insert(list);
    }

    @Override
    public void deleteByUserIds(Long[] userIds) {
        LambdaUpdateWrapper<SysUserPost> updateWrapper = new LambdaUpdateWrapper<SysUserPost>()
                .in(SysUserPost::getUserId, userIds);
        userPostMapper.delete(updateWrapper);
    }
}
